const fp=require('lodash/fp')
const {Maybe, Container}=require('./support')
let maybe = Maybe.of([5,6,1])
let xs=Container.of(['do','ray','me','fa','so','la','ti','do'])
//练习1
let ex1=()=>{
  return maybe.map(x => fp.map(y => fp.add(y, 2), x))
}
console.log(ex1()._value)

// 练习2
let ex2=()=>{
  return xs.map(x=>fp.first(x))
}
console.log(ex2()._value)

//练习3
let safeProp=fp.curry(function(x,o){ 
  return Maybe.of(o[x])
})
let user ={ id:2,name:'Albert'}
let ex3=()=>{
  return safeProp('name',user).map(x=>fp.first(x))
}
console.log(ex3()._value)

//练习4
let ex4=function(n){
  return Maybe.of(n).map(n=>parseInt(n))._value
}
console.log(ex4('20.5'));